#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;
const int B = 450;

int n, m, Q, tim[N], col[N], btim[N], bcol[N];
bool b[N];
vec G[N], bG[N];

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in, m = in, Q = in;
	rep(i, 1, m) { int u = in, v = in; G[u].pb(v); G[v].pb(u); }
	rep(i, 1, n) if(G[i].size() > B) b[i] = true;
	rep(i, 1, n) for(auto y : G[i]) if(b[y]) bG[i].pb(y);
	rep(i, 1, n) tim[i] = 0, col[i] = i;
	rep(i, 1, Q) {
		int x = in;
		for(auto y : bG[x]) if(btim[y] > tim[x]) tim[x] = btim[y], col[x] = bcol[y];
		if(!b[x]) {
			tim[x] = i;
			for(auto y : G[x]) col[y] = col[x], tim[y] = i;
		} else { tim[x] = btim[x] = i; bcol[x] = col[x]; }
	}
	rep(i, 1, n) {
		for(auto y : bG[i]) if(btim[y] > tim[i]) tim[i] = btim[y], col[i] = bcol[y];
	}
	rep(i, 1, n) printf("%d ", col[i]); return 0;
}
